<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					<a href="#">系统首页</a>
				</li>
				<li class="active">
					基础数据管理
				</li>
	            <li>
					<a href="#">设备类型</a>
				</li>
	            <li class="active">
					新增
				</li>
			</ul><!-- .breadcrumb -->
		</div>
		<div class="page-content">
        
        <div class="page-header">
			<h1>新增设备类型</h1>
		</div>
		<div class="row">
			 <div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->

				<form id="usrform" action="<?php echo base_url()."admin/basis_data/add_device_type"?>" method="post">
				    <div class="box-body" style="display: inline-block;width: 100%">
				        <div class="form-group col-xs-6">
				            <label>二级编码</label><span style="color: #a94442;"><?php echo form_error("number")?></span>
				            <input name="number" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('number');?>" check-type="required">
			            </div>
				        <div class="form-group col-xs-6">
				            <label>类型名称</label><span style="color: #a94442;"><?php echo form_error("name")?></span>
				            <input name="name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('name');?>" check-type="required">
			            </div>
                        <div class="form-group col-xs-6">
				            <label>所属大类</label><span style="color: #a94442;"><?php echo form_error("category_id")?></span>
				            <select name="category_id" id="category_id" class="form-control" check-type="required">
                            <option value="">全部</option>
                            <?php if (isset($category)){
                                foreach ($category as $val){
                            ?>
							<option value="<?php echo $val->id;?>" <?php if (set_value('category_id') == $val->id)echo "selected";?>><?php echo $val->name;?></option>
							<?php }
                                }?>
						    </select>
			            </div>
			            <div class="form-group col-xs-6">
				            <label>参数A名称：</label>
				            <input name="load_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('load_name');?>">
			            </div>
			            <div class="form-group col-xs-6">
				            <label>参数A内容：</label>
				            <input name="load" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('load');?>"  >
			            </div>
			            <div class="form-group col-xs-6">
				            <label>参数B名称：</label>
				            <input name="capacity_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('capacity_name');?>" >
			            </div>
			            <div class="form-group col-xs-6">
				            <label>参数B内容：</label>
				            <input name="capacity" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value('capacity');?>" >
			            </div>
			            <div class="form-group col-xs-6">
                            <label>备注</label>
                            <textarea class="form-control" style="height:60px" name="note"><?php echo set_value('note');?></textarea>
                        </div>
                        <div class="form-group col-xs-6">
			            	<div id="select" style="width: 150px; margin-bottom: 20px;">
	  							<input type="hidden" id="url" name="headpic" value="" check-type="required">
	    						<img id="headpic" style="width: 100%;" src="<?php echo base_url()?>themes/default/images/photo_icon.png" />
							</div>
							<div><a class="btn_style" onClick='del_img()' >删除logo</a></div>
		            	</div>
                        </div>
			            <div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button id="btnSubmit" class="btn btn-info" type="submit">
								<i class="icon-ok bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp; &nbsp;
							<a class="btn" href="<?php echo base_url()."admin/basis_data/device_type"?>">
								<i class="icon-undo bigger-110"></i>
								返回
							</a>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
				<script type="text/javascript">
	$("#usrform").validation();
	//保存
	$("#btnSubmit").on('click',function(event){
	  // 2.最后要调用 valid()方法。
	  if ($("#usrform").valid()==false){
	    return false;
	  }
	});
	</script>
	<script>
	function del_img(){
		$('#headpic').attr('src','<?php echo base_url()?>themes/default/images/photo_icon.png');
        $('#url').val('');
	}
    $(function () {
        var uploader = null;
        //上传初始化
		if(uploader==null){
        	uploader = WebUploader.create({
        	    // 选完文件后，是否自动上传。
        	    auto: true,
        	    //不压缩图像
        	    compress:false,
        	    // swf文件路径
        	    swf:'<?php echo base_url()?>themes/webuploader/Uploader.swf',
        	    // 文件接收服务端。
        	    server: '<?php echo site_url("admin/upyun/webuploader")?>',
        	    // 选择文件的按钮。可选。
        	    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        	    pick: '#select',
        	    // 只允许选择图片文件。
        	    accept: {
        	        title: 'Images',
        	        extensions: 'gif,jpg,jpeg,bmp,png',
        	        mimeTypes: 'image/*'
        	    }
        	});
        	//文件上传成功，显示图片。
        	uploader.on('uploadSuccess', function(file,response) {
        		$('#headpic').attr('src',response.file_path);
        		uploader.reset();
        		$('#url').val(response.file_path);
        	});

        	// 文件上传失败，显示上传出错。
        	uploader.on( 'uploadError', function( file ) {
        		$('#error').html('上传失败');
        		$('#error').show();
        	});
		}
    });
    </script>